class Solution:
    def coinChange(self, coins: List[int], amount: int) -> int:
        dp = [amount + 1] * (amount + 1)
        dp[0] = 0
        # 枚举每一个金额
        for a in range(1, amount + 1):
            # 枚举每一种硬币
            for c in coins:
                if a - c < 0:continue
                dp[a] = min(dp[a], dp[a - c] + 1)
        return dp[amount] if dp[amount] <= amount else -1